package com.webkit.web;

import javax.servlet.http.HttpServletRequest;

import com.lamfire.logger.Logger;
import com.lamfire.utils.ObjectUtils;
import com.webkit.web.action.Action;

final class WebKitRequestWrapper extends AbstractRequestWrapper {

	private static final Logger LOGGER = Logger.getLogger(WebKitRequestWrapper.class);

	public WebKitRequestWrapper(HttpServletRequest request) {
		super(request);
	}

	private Action action;

	@Override
	public Object getAttribute(String name) {
		if (action != null) {
			try {
				Object obj = ObjectUtils.getPropertyValue(action, name);
				if (obj != null) {
					LOGGER.debug("get action's property [" + name + "] = " + obj);
					return obj;
				}
			} catch (Exception e) {
				
			}
		}

		return super.getAttribute(name);

	}

	public void setAction(Action action) {
		this.action = action;
	}

	public boolean isMultipartRequest() {
		String content_type = getContentType();
		if ((content_type != null) && (content_type.indexOf("multipart/form-data") != -1)) {
			return true;
		}
		return false;
	}
	
	
}
